package com.lc1993929.mr.rating;

import lombok.Data;
import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Created by LiuChang on 2018/1/18.
 */
@Data
public class SortBean implements WritableComparable<SortBean> {
    private String movie;
    private Integer counts;

    @Override
    public int compareTo(SortBean o) {
        return o.getCounts().compareTo(this.counts);
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(movie);
        dataOutput.writeInt(counts);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.movie = dataInput.readUTF();
        this.counts = dataInput.readInt();
    }
}
